/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSValueElement.h
 *
 *  Created on: 2010/03/08
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSVALUEELEMENT_H_
#define RSVALUEELEMENT_H_

#include "RSElement.h"

namespace Realsphere {

    class RSValueElement : public Realsphere::RSElement {
        Q_OBJECT
        Q_PROPERTY ( QString _attr_sid READ ScopeId WRITE SetScopeId )
        public:
            RSValueElement ( const QString& rScopeId = QString::null );

        public:
            QString                     ScopeId () const;

            virtual RSValueType         ValueType () const = 0;
            virtual RSDataPointer       DataPointer() = 0;
            virtual RSDataSize          SizeOf () const = 0;
            virtual QString             ToString () const = 0;

            bool                        IsRootElement() const;

        public slots:
            void                        SetScopeId ( const QString& rScopeId, bool rEmit = true );

        signals:
            void                        ScopeIdChanged ( const QString& rScopeId );
            void                        ValueChanged ();

        protected:
            virtual RSError                 BeforeAddChildElement ( Realsphere::RSElement* rElement );

        protected:
            void                        WriteElementData ( QXmlStreamWriter* rXmlWriter );

        private:
            QString                     mScopeId;
    };

}

#endif /* RSVALUEELEMENT_H_ */
